﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PiaoanWeb.AppLogic.BusinessLogicLayer;
using PiaoanWeb.AppLogic.DataAccessLayer;
namespace PiaoanWeb.Admin
{
    public partial class EditBlock : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && !string.IsNullOrEmpty(Request.QueryString["T"]))
            {
                Title = Request.QueryString["T"];
                titleLbl.Text = Request.QueryString["T"];

                BlocksBLL blocksBLL = new BlocksBLL();
                BlockContent blockContent = blocksBLL.GetBlockContentByBlockName(Request.QueryString["T"]);
                contentTxtbox.Text = blockContent.Content;
            }
        }

        protected void saveBtn_Click(object sender, EventArgs e)
        {
            BlocksBLL blocksBLL = new BlocksBLL();
            BlockContent blockContent = blocksBLL.GetBlockContentByBlockName(Request.QueryString["T"]);
            blockContent.Content = contentTxtbox.Text;
            blocksBLL.Save();
            Response.Redirect("Block.aspx?T=" + Request.QueryString["T"]);
        }

        protected void cancelBtn_Click(object sender, EventArgs e)
        {
            Response.Redirect("Block.aspx?T=" + Request.QueryString["T"]);
        }
    }
}